home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util4 / 0utils.lha / 0Utils / Tackon.data < prev    next >
Text File  |  1995-08-19  |  3KB  |  123 lines

  1.  
  2. #ifdef TPLTER
  3.  
  4. Tackon = {
  5.  
  6.     SHORT = {{ join path, filename and suffix }};
  7.  
  8.     DESCRIPTION = {{
  9.     Tackon gets a filename and perhaps a pathname and a
  10.     suffix and creates a new filename out of them.
  11.  
  12.     To add correctly filename to pathname we use AmigaDOS.
  13.  
  14.     If the suffix starts with a "." or "_" (any non
  15.     alnum character), it is directly appended to the
  16.     full filename;
  17.     if suffix starts with an alphanumeric char,
  18.     a "." is prepended.
  19.  
  20.     The resulting string is sent to STDOUT
  21.  
  22.      RESULT
  23.     a filename created with the inputs.
  24.     }};
  25.  
  26.     BUGS = {{
  27.     * there is no check (yet), if suffix is itself a path
  28.     * the resulting filename must not be bigger than 256 chars
  29.     there is a strange behaviour if compiled w/ DICE;
  30.     * I cannot say why, but If You do not specify
  31.     each input-slot, You will get a Enforcer-Hits;
  32.     for that reason, I'll distribute Chris' SAS-executable
  33.     }};
  34.  
  35.     EXAMPLES = {{
  36.     >Tackon x: a:b _c
  37.     a:b_c
  38.  
  39.     >Tackon x:a b c
  40.     x:a/b.c
  41.  
  42.     > tackon xx yy zz
  43.     xx/yy.zz
  44.  
  45.     > tackon xx :yy -zz
  46.     :yy-zz
  47.     }};
  48.  
  49.     SEEALSO = {{
  50.     dos.library/AddPart
  51.     Suffix, PathPart, FilePart
  52.     }};
  53.  
  54.     HISTORY = {{
  55.     01-08-93 b_noll created
  56.     20-02-95 b_noll restructured source, removed mstrcpy
  57.     21-02-95 b_noll added version/format-prefix/offset
  58.     27-02-95 b_noll removed an Enforcer Hit (huch!)
  59.     20-03-95 b_noll added args diagnostics
  60.     20-03-95 b_noll fixed crash, if resultstring was too large,
  61.             always returned RETURN_WARN
  62.     19-08-95 b_noll created .data file
  63.     }};
  64.  
  65.  
  66.  
  67.     includes = { "<strings.h>" };
  68.  
  69.  
  70.  
  71. Template = "PATH,NAME/A,SUFFIX";
  72. Arguments = {{
  73.     STRPTR path;
  74.     STRPTR name;
  75.     STRPTR suffix;
  76.  
  77. #define isalnum(x) ((((x) <= '9') && ((x >= '0'))) || (((x) <= 'Z') && ((x >= 'A'))) || (((x) <= 'z') && ((x >= 'a'))))
  78. #define BODY(x)      do{ x }while(0)
  79. #define findlast(s)  BODY(char*td=(s);while(*td) ++td; (s)=td;)
  80. }};
  81.  
  82.     version = "1.2";
  83.  
  84.     body = {{
  85.         char* b2;
  86.         char* buffer;
  87.         if (buffer = AllocMem(MAXPATHLEN, 0)) {
  88.  
  89.         retval    = RETURN_WARN;
  90.         *buffer = 0;
  91.  
  92.         strcpy (buffer, argv->path);
  93.  
  94.         if (AddPart (buffer, argv->name, MAXPATHLEN-1)) {
  95.  
  96.             b2 = buffer;
  97.             while (*b2) ++b2;
  98.             if (argv->suffix) {
  99.             if (isalnum(*argv->suffix)) {
  100.                 *b2   = '.';
  101.                 ++b2;
  102.                 *b2 = 0;
  103.             } /* if */
  104.             } /* if */
  105.  
  106.             if (!PutStr (buffer)) retval = RETURN_OK;
  107.             if (argv->suffix)
  108.             PutStr (argv->suffix);
  109.  
  110.             PutStr ("\n");
  111.         } else {
  112.             //SetIoErr(ERROR_OBJECT_TOO_LARGE);
  113.         } /* addpart */
  114.         FreeMem (buffer, MAXPATHLEN);
  115.         } /* if */
  116.  
  117.     }};
  118.  
  119. };
  120.  
  121. #endif
  122.  
  123.